Skip to content

Spanner Cassandra ITs - Fix non-idempotent Cassandra schema creation#3409

Merged
darshan-sj merged 1 commit intoGoogleCloudPlatform:mainfrom
darshan-sj:spanner-it
Feb 25, 2026
Merged

Spanner Cassandra ITs - Fix non-idempotent Cassandra schema creation#3409
darshan-sj merged 1 commit intoGoogleCloudPlatform:mainfrom
darshan-sj:spanner-it

Conversation

@darshan-sj
Copy link
Contributor

This PR addresses intermittent AlreadyExistsException failures in Cassandra-based integration tests (specifically CassandraAllDataTypesIT).

Example: https://github.com/GoogleCloudPlatform/DataflowTemplates/actions/runs/22293136720/job/64485274459?pr=3380 https://github.com/GoogleCloudPlatform/DataflowTemplates/actions/runs/22366068580/job/64734193159

The issue stems from the interaction between the CassandraResourceManager's retry policy (via dev.failsafe) and non-idempotent CSQL statements. When Cassandra is under load, a CREATE TABLE statement may succeed on the server but fail to return a response to the client within the timeout window. Failsafe then triggers a retry, which fails immediately because the table was successfully created in the first attempt.

Changes
Updated the CSQL resource files to use IF NOT EXISTS for all CREATE TABLE statements. Ensures that schema setup is idempotent, allowing the CassandraResourceManager to safely retry without failing the test suite.

Unlike CREATE TABLE statements, INSERT statements in Casandra are natively upserts and doesn't cause errors on retry.

@darshan-sj darshan-sj marked this pull request as ready for review February 25, 2026 09:11
@darshan-sj darshan-sj requested a review from a team as a code owner February 25, 2026 09:11
@gemini-code-assist
Copy link

Summary of Changes

Hello @darshan-sj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of Cassandra-based integration tests by preventing AlreadyExistsException failures during schema setup. By making table creation idempotent, the system can safely retry operations without encountering errors, thereby improving the stability and reliability of the test suite.

Highlights

  • Idempotent Cassandra Schema Creation: Modified all CREATE TABLE statements in Cassandra test schema files to include the IF NOT EXISTS clause, ensuring that table creation operations are idempotent.
  • Removed Redundant DROP TABLE Statements: Removed DROP TABLE IF EXISTS statements from cassandra-data-types.csql and cassandra-transformation-schema.sql as they are no longer necessary with idempotent CREATE TABLE.
Changelog
  • v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/cassandra-data-types.csql
    • Modified CREATE TABLE all_data_types to include IF NOT EXISTS and removed the preceding DROP TABLE statement.
    • Modified CREATE TABLE "true" to include IF NOT EXISTS.
  • v2/spanner-to-sourcedb/src/test/resources/SpannerCassandraReservedKeywordsIT/cassandra-schema.cql
    • Modified CREATE TABLE "true" to include IF NOT EXISTS.
  • v2/spanner-to-sourcedb/src/test/resources/SpannerToCassandraSourceIT/cassandra-schema.sql
    • Modified CREATE TABLE users to include IF NOT EXISTS.
    • Modified CREATE TABLE users2 to include IF NOT EXISTS.
    • Modified CREATE TABLE AllDatatypeTransformation to include IF NOT EXISTS.
    • Modified CREATE TABLE AllDatatypeColumns to include IF NOT EXISTS.
    • Modified CREATE TABLE BoundaryConversionTestTable to include IF NOT EXISTS.
    • Modified CREATE TABLE EmptyStringJsonTable to include IF NOT EXISTS.
    • Modified CREATE TABLE testtable_03tpcovf16ed0klxm3v808ch3btgq0uk to include IF NOT EXISTS.
  • v2/spanner-to-sourcedb/src/test/resources/SpannerToCassandraSourceIT/cassandra-transformation-schema.sql
    • Modified CREATE TABLE customers to include IF NOT EXISTS and removed the preceding DROP TABLE statement.
  • v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbWideRowIT/cassandra-10mb-schema.sql
    • Modified CREATE TABLE large_data to include IF NOT EXISTS.
Activity
  • No review comments or other activity found in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@darshan-sj darshan-sj merged commit d964ea1 into GoogleCloudPlatform:main Feb 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants